import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:pdf_render/pdf_render_widgets.dart';

import '../../base/MyScaffold.dart';
import '../../model/PDFFile.dart';
import '../../utils/color/ColorUtils.dart';
import '../../widgets/TextView.dart';

class FileInfo extends StatefulWidget {
  FileInfo({Key? key, required this.pdfFile}) : super(key: key);
  PDFFile pdfFile;

  @override
  State<FileInfo> createState() => _FileInfoState();
}

class _FileInfoState extends State<FileInfo> {
  @override
  Widget build(BuildContext context) {
    return MyScaffold(
      title: "file_information".tr,
      body: Container(
        margin: const EdgeInsets.only(top: 40),
        alignment: Alignment.center,
        child: Column(
          children: [
            Container(
              margin: const EdgeInsets.only(right: 12),
              width: 56,
              height: 56,
              decoration: BoxDecoration(
                  borderRadius: BorderRadius.circular(6),
                  border:
                      Border.all(color: rgba(230, 231, 235, 1), width: 0.5)),
              alignment: Alignment.center,
              child: PdfDocumentLoader.openFile(
                widget.pdfFile.path,
                pageNumber: 1,
              ),
            ),
            TextView(
              widget.pdfFile.name,
              padding: const EdgeInsets.symmetric(horizontal: 70),
              maxLines: 3,
              textAlign: TextAlign.center,
              style: TextStyle(color: ColorUtils.text_),
              margin: const EdgeInsets.only(top: 24, bottom: 40),
            ),
            const Divider(),
            Container(
              margin: const EdgeInsets.all(16),
              child: Row(
                children: [
                  TextView(
                    "size".tr,
                    style: TextStyle(color: ColorUtils.text),
                  ),
                  const Spacer(),
                  TextView(widget.pdfFile.size.toString(),
                      style: TextStyle(color: ColorUtils.text_))
                ],
              ),
            ),
            Container(
              margin: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
              child: Row(
                children: [
                  TextView(
                    "type".tr,
                    style: TextStyle(color: ColorUtils.text),
                  ),
                  const Spacer(),
                  TextView("PDF", style: TextStyle(color: ColorUtils.text_))
                ],
              ),
            ),
            Container(
              margin: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
              child: Row(
                children: [
                  TextView(
                    "location".tr,
                    style: TextStyle(color: ColorUtils.text),
                  ),
                  const SizedBox(
                    width: 50,
                  ),
                  Expanded(
                    child: TextView(widget.pdfFile.path,
                        textAlign: TextAlign.left,
                        maxLines: 4,
                        style: TextStyle(color: ColorUtils.text_)),
                  )
                ],
              ),
            ),
            Container(
              margin: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
              child: Row(
                children: [
                  TextView(
                    "last_modified".tr,
                    style: TextStyle(color: ColorUtils.text),
                  ),
                  const Spacer(),
                  TextView(widget.pdfFile.time,
                      style: TextStyle(color: ColorUtils.text_))
                ],
              ),
            ),
          ],
        ),
      ),
    );
  }
}
